<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 验证哥德巴赫猜想。一个偶数可以拆分成两个质数之和

    //方法定义
    //是否是质数
    function isZhishu(num){
        for(var i = 2; i<= parseInt(Math.sqrt(num)); i++){
            if(num % i == 0){
                return false;
            }
        }
        return true;
    }

    //获取质数数组
    function getNum (num){
        for(var i = 0; i < num; i++){
              if(isZhishu(i) && isZhishu(num - i)){
                return [i,num-i];
              }
        }
    }

    //主程序
    var num = parseInt(prompt("请输入一个偶数，验证哥德巴赫"));
    alert("偶数 " + num + " 可拆分为：" + getNum(num))
</script>
</html>